home *** CD-ROM | disk | FTP | other *** search
- unit Demo3;
-
- interface
-
- uses
- SysUtils, WinTypes, WinProcs, Messages, Classes, Graphics, Controls,
- StdCtrls, Forms, DBCtrls, DB, DBGrids, Buttons, DBTables, Grids,
- ExtCtrls, Printers, PrnGridR;
-
- type
- TDemo3Form = class(TForm)
- DBGrid1: TDBGrid;
- Panel1: TPanel;
- DataSource1: TDataSource;
- Panel2: TPanel;
- Query1: TQuery;
- Label1: TLabel;
- Label2: TLabel;
- Preview: TBitBtn;
- Exit: TBitBtn;
- Query1PartNo: TFloatField;
- Query1VendorNo: TFloatField;
- Query1Description: TStringField;
- Query1OnHand: TFloatField;
- Query1OnOrder: TFloatField;
- Query1Cost: TCurrencyField;
- Query1ListPrice: TCurrencyField;
- Query1OnOrderValue: TCurrencyField;
- Query1OnHandValue: TCurrencyField;
- Label3: TLabel;
- PrintGridReport1: TPrintGridReport;
- procedure FormCreate(Sender: TObject);
- procedure PreviewClick(Sender: TObject);
- procedure Query1CalcFields(DataSet: TDataset);
- private
- { private declarations }
- public
- end;
-
- var
- Demo3Form: TDemo3Form;
-
- implementation
-
- {$R *.DFM}
-
- procedure TDemo3Form.FormCreate(Sender: TObject);
- begin
- Query1.Open;
-
- { SubTotals will be on field VenderNo}
- PrintGridReport1.SetSubTotalField(1, 'VendorNo');
-
- { Do not total next 3 fields, but do all the rest }
- PrintGridReport1.SetPrintTotal('Cost', False);
- PrintGridReport1.SetPrintTotal('ListPrice', False);
- PrintGridReport1.SetPrintTotal('VenderNo', False);
- end;
-
- procedure TDemo3Form.PreviewClick(Sender: TObject);
- begin
- { Force Orientation to Landscape }
- PrintGridReport1.Orientation := Landscape;
-
- { and send query for preview }
- PrintGridReport1.Execute;
- Printer.Orientation := poPortrait;
- end;
-
-
- procedure TDemo3Form.Query1CalcFields(DataSet: TDataset);
- begin
- Query1OnOrderValue.Value := Query1OnOrder.Value*Query1Cost.Value;
- Query1OnHandValue.Value := Query1Cost.Value*Query1OnHand.Value;
- end;
-
-
- end.